home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_c
/
cuj0696.zip
/
DWYER.ZIP
/
SPECTRAL.TST
/
XMOD.CX
< prev
next >
Wrap
Text File
|
1995-08-06
|
844b
|
33 lines
/* ============ */
/* xmod.cx */
/* ============ */
#include <xtendefs.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* ==================================================================== */
/* Xmod - Calculates remainder of XA / XB (XA mod XB) */
/* ==================================================================== */
void
Xmod(USHORT *XA, USHORT *XB, USHORT *XREM)
{
USHORT MyXA[NE], MyXB[NE];
USHORT Sign = (USHORT)(XTST(XA) > 0);
XCOPY(XA, MyXA), XABS(MyXA);
XCOPY(XB, MyXB), XABS(MyXB);
XDIV(MyXA, MyXB, XREM); /* A / B -> XREM */
XFLOOR(XREM, XREM); /* Integer Part */
XRMULT(XREM, MyXB); /* [A/B] * B */
if (Sign)
{
XSUB(MyXA, XREM, XREM); /* + Remainder */
}
else
{
XSUB(XREM, MyXA, XREM); /* - Remainder */
}
}